package com.saicyc.demo.utils;



import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;

import javax.persistence.AttributeConverter;

@Slf4j
public class DateToStringConverter implements AttributeConverter<String, String> {


    @Override
    public String convertToDatabaseColumn(String attribute) {
        if (StringUtils.isNotBlank(attribute)) {
            int i = attribute.indexOf(".");
            return i != -1 ? attribute.substring(0, i) : attribute;
        } else {
            return null;
        }
    }

    @Override
    public String convertToEntityAttribute(String attribute) {
        if (StringUtils.isNotBlank(attribute)) {
            int i = attribute.indexOf(".");
            return i != -1 ? attribute.substring(0, i) : attribute;
        } else {
            return null;
        }
    }
}
